package main

import (
	"martini_template/bootstrap"
	"martini_template/componnet"
	"martini_template/cronjob"
	"martini_template/database"
	"os"
)

func main() {
	defer func() { // 捕获panic异常
		if err := recover(); err != nil {
			componnet.Elogger.Println(err)
		}
	}()
	//获取编译环境
	if len(os.Args) > 1 {
		if os.Args[1] == componnet.ENV_DEV || os.Args[1] == componnet.ENV_TEST || os.Args[1] == componnet.ENV_PROD {
			componnet.ENV = os.Args[1]
		}
	}
	//启动定时任务
	go cronjob.Run()
	//App初始化
	bootstrap.InitApp()
	database.InitDb(componnet.ENV)
	bootstrap.InitRouter()
	bootstrap.AppRun()
}
